package com.hc.contorl;

import com.hc.pojo.TbUser;
import com.hc.service.TbUserService;
import com.hc.service.impl.TbUserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@WebServlet(value = "/userLike")
public class UserLikeContorller extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");

        String sear=req.getParameter("search");
        Map<String,String> map=new HashMap<>();
        String username=req.getParameter("username");
        String phone=req.getParameter("phone");
        String email=req.getParameter("email");
        map.put("search",sear);
        map.put("username",username);
        map.put("phone",phone);
        map.put("email",email);
        System.out.println("search:"+map.get("search"));
        System.out.println("username:"+map.get("username"));
        System.out.println("phone:"+map.get(phone));
        System.out.println("email:"+map.get("email"));
        TbUserService service=new TbUserServiceImpl();
        List<TbUser> users=service.likeSearch(map);
        req.setAttribute("userList",users);
        req.getRequestDispatcher("user_list.jsp").forward(req,resp);
    }


}
